package ynu.edu.stats.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ynu.edu.common.domain.R;
import ynu.edu.common.domain.stats.CategoryStat;
import ynu.edu.common.domain.stats.StatsData;
import ynu.edu.common.domain.stats.UserGrowthData;
import ynu.edu.stats.service.StatsService;

import java.util.List;


@RestController
@RequestMapping("/stats")
@RequiredArgsConstructor
@Slf4j
@Api(tags = "统计服务")
public class StatsController {

    private final StatsService statsService;

    @ApiOperation("商品统计")
    @GetMapping("/item")
    public R<StatsData<List<CategoryStat>>> getItemStats() {
        return R.ok(statsService.getItemStats());
    }

    @ApiOperation("最近七天用户统计")
    @GetMapping("/user/growth")
    public R<StatsData<UserGrowthData>> getUserGrowthStats() {
        return R.ok(statsService.getUserGrowthStats());
    }
}